#!/usr/bin/env python3

if __name__ == '__main__':
    import os, sys
    arguments = sys.argv[1:]
    # file_name
    run_file_name = arguments[0]

    extra_args = ''
    if len(arguments) > 1:
        extra_args = f"{' '.join(arguments[1:])} "

    os.environ['PARALLEL_TYPE'] = 'ddp'

    if len(extra_args) == 0:
        extra_args = '--standalone --nproc_per_node=gpu '

    command = f'torchrun {extra_args}{run_file_name}'

    print(f'run command {command}')
    os.system(command)
